package me.xiaoyan.android.tuition.activity.core;

import me.xiaoyan.android.tuition.R;
import me.xiaoyan.android.tuition.activity.About;
import me.xiaoyan.android.tuition.activity.Help;
import me.xiaoyan.android.tuition.activity.QueryOrder;
import me.xiaoyan.android.tuition.activity.Schools;
import me.xiaoyan.android.tuition.utils.AppManager;
import me.xiaoyan.android.tuition.utils.TuitionException;
import me.xiaoyan.android.widget.DataBackListener;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;

public class Main extends MainActivity {
	@SuppressLint("HandlerLeak")
	private Handler handler = new Handler() {
		@Override
		public void handleMessage(Message msg) {
			DataBackListener dbl = (DataBackListener) msg.obj;
			String source = msg.getData().getString("source");
			switch (msg.what) {
			case 0:
				dbl.success(source);
				break;
			default:
				dbl.failed(new TuitionException(msg.what, source));
				break;
			}
		}
	};

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		AppManager.getInstance().setHandler(handler);
	}

	@Override
	protected int getLayoutResourceId() {
		return R.layout.activity_main;
	}

	@Override
	protected int[] getRadioButtonIds() {
		return new int[] { R.id.nav_btn_home, R.id.nav_btn_orders,
				R.id.nav_btn_help, R.id.nav_btn_about };
	}

	@Override
	protected int[] getRadioButtonImageIds() {
		return null;
	}

	@Override
	protected int[] getRadioButtonTexts() {
		return null;
	}

	@SuppressWarnings("unchecked")
	@Override
	public Class<Activity>[] getClasses() {
		Class<Activity>[] classes = new Class[] { Schools.class,
				QueryOrder.class, Help.class, About.class };
		return classes;
	}

	@Override
	protected int getContentContainerId() {
		return R.id.activitiesContainer;
	}

	@Override
	protected int getRadioGroupId() {
		return R.id.navbar;
	}

}
